﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.Common.BLL;
using Yipusoft.Common.Model;

public partial class BasicBase_FireProject_FireProjectQurey : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            init();
        }
    }

    void init()
    {
        string strWhere = " ParentID='MHJYYALB0000' ";
        List<CodeItemInfo> list = CodeItem.GetList(strWhere);
        ddlTypeID.Items.Add("");
        for (int i = 0; i < list.Count; i++)
        {
            ddlTypeID.Items.Add(new ListItem(list[i].ItemName, list[i].ItemID));
        }
    }

    protected void lbtQurey_Click(object sender, EventArgs e)
    {

        if (!Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "201300") && !Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "201304"))
        {
            Response.Write("<script>alert('没有权限！');history.back(0);</script>");
            return;
        }
        string strWhere = "";
        if (UCDepartmentISEmp1.GetDepartmentID() != "")
        {
            strWhere += " DepartmentID='" + UCDepartmentISEmp1.GetDepartmentID() + "' ";
        }
        else
        {
            if (UCDepartmentISEmp1.GetParentDepartment() != "")
            {
                strWhere += " DepartmentID like '" + UCDepartmentISEmp1.GetParentDepartment().Substring(0, 4) + "%'";
            }
            else
            {
                string Departmentid = Yipusoft.Account.BLL.User.GetUser(Page.User.Identity.Name).DepartmentID;
                if (Yipusoft.Account.BLL.User.HasPermission(Page.User.Identity.Name, "201301"))//总队级
                {

                }
                else if (Yipusoft.Account.BLL.User.HasPermission(Page.User.Identity.Name, "201302"))//支队级
                {
                    strWhere += " DepartmentID like '1300%' or DepartmentID like '" + Departmentid.Substring(0, 4) + "%'";
                }
                else if (Yipusoft.Account.BLL.User.HasPermission(Page.User.Identity.Name, "201310"))//中队级
                {
                    strWhere += " DepartmentID like '" + Departmentid.Substring(0, 4) + "%'";
                }
                else if (Yipusoft.Account.BLL.User.HasPermission(Page.User.Identity.Name, "201303"))//本单位级
                {

                }
            }
        }
        if (ddlTypeID.SelectedValue != "")
        {
            if (strWhere.Length != 0)
            {
                strWhere += " and ";
            }

            strWhere += " TypeID='" + ddlTypeID.SelectedValue + "' ";

        }
        if (ddlClassID.SelectedValue != "")
        {
            if (strWhere.Length != 0)
            {
                strWhere += " and ";
            }
            strWhere += " ClassID='" + ddlClassID.SelectedValue + "' ";
        }
        if (ProjectName.Text != "")
        {
            if (strWhere.Length != 0)
            {
                strWhere += " and ";
            }
            strWhere += " ProjectName like '%" + ProjectName.Text + "%' ";
        }
        Response.Redirect("FireProjectList.aspx?where=" + strWhere);
    }

    protected void ddlTypeID_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindDDlClassid();
    }

    void BindDDlClassid()
    {
        if (ddlTypeID.SelectedValue != "")
        {
            ddlClassID.Items.Clear();
            ddlClassID.Items.Add("");
            List<CodeItemInfo> list = CodeItem.GetList(" ParentID='" + ddlTypeID.Text + "' ");

            for (int i = 0; i < list.Count; i++)
            {
                ddlClassID.Items.Add(new ListItem(list[i].ItemName, list[i].ItemID));
            }
        }
        else
        {
            ddlClassID.Items.Clear();
        }
    }

}
